package com.zxp.common.codegen.pojo;


import com.zxp.common.codegen.constant.DbType;
import lombok.Getter;
import lombok.Setter;

/**
 * 数据库实体类
 */
public class DataBase {

    @Getter @Setter
    private DbType dbType;//数据库类型

    @Getter @Setter
    private String host;

    @Getter @Setter
    private String username;

    @Getter @Setter
    private String password;

    @Getter
    private String url;

    private DataBase() {}

    public DataBase(DbType dbType) {
        this(dbType,"127.0.0.1","3306","");
    }

    public DataBase(DbType dbType,String db) {
        this(dbType,"127.0.0.1","3306",db);
    }
    public DataBase(DbType dbType,String host, String db) {
        this(dbType,host,"3306",db);
    }

    /**
     *
     * @param dbType        数据库类型
     * @param host          主机： ip或者RDS地址，如阿里云RDS
     * @param port          3306
     * @param db            ihrm
     */
    public DataBase(DbType dbType,String host,String port,String db) {
        this.dbType = dbType;
        this.host=host;
        this.url= String.format(dbType.getJdbcUrl(), host, port,db);
    }

}
